package com.itheima.request;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @Author: yg
 * @create 2025-02-04 - 20:56
 * @
 */
@WebServlet("/req3")
public class RequestDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("req3...");
        //请求转发
        req.getRequestDispatcher("/req4").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取post请求体：请求参数
        //2.获取字符输入流
        BufferedReader bf = req.getReader();
        //3.读取数据
        String line = bf.readLine();
        System.out.println(line);

    }
}
